Data for use by a processing unit typically comprises a number of bits. Data values can be represented by bits according to a number of different formats. For example, data values may be normalized data values which represent a number within a particular range. For example, a number may be represented using an n-bit UNORM value which is an unsigned normalized integer representing 2n evenly spaced values between and including 0 and 1. For example, 0 is represented by an n-bit UNORM value with all n bits being zero, and 1 is represented by an n-bit UNORM value with all n bits being one.
As another example, a number may be represented using an n-bit SNORM value which is a signed normalized integer. The maximum signed n-bit value represents +1 whilst the minimum signed n-bit value represents −1. In addition the second-minimum signed n-bit value also represents −1 such that there are two representations for −1. This results in a set of integer representations for evenly spaced values in the range −1 to 0, and also a complementary set of representations for evenly spaced values in the range 0 to 1.
As described above, an n-bit UNORM value is an unsigned n-bit integer, x, interpreted as representing a number given by:
      x                  2        n            -      1        .
Since the UNORM value, x, is an integer, only particular numbers within the range from 0 to 1 can be represented. For example, for a 2-bit UNORM value, the bits ‘00’ represent 0, the bits ‘01’ represent ⅓, the bits ‘10’ represent ⅔ and the bits ‘11’ represent 1. It can be appreciated, for example, that there is no n-bit UNORM value which exactly represents ½. Furthermore, it can be shown that there is no n-bit UNORM value which represents a value exactly halfway between the values represented by two consecutive m-bit UNORM values.
A normalized n-bit value may be converted into a normalized m-bit value, where n≠m. A conversion such as this may be used by a processing unit acting on the data for one of many different reasons as would be apparent to a person skilled in the art.
An m-bit UNORM value is an unsigned m-bit integer, y, interpreted as representing a number given by:
      y                  2        m            -      1        .
Therefore, the m-bit UNORM value, y, which corresponds to the n-bit UNORM value, x, is given by:
                    y        =                                                            2                m                            -              1                                                      2                n                            -              1                                ⁢                      x            .                                              (        1        )            
However, according to the UNORM data format, the m-bit UNORM value, y, must be an integer, so equation (1) shown above may require some rounding in order to find an integer value for y. Different rounding techniques may be used, such as round to zero (RTZ), round to positive infinity (RTP), round to negative infinity (RTN) and round to the nearest integer (e.g. RTE which is round to nearest, ties to even; or RTU which is round to nearest, ties to upper).
One way to calculate the value of y in accordance with equation (1) is to perform a multiplication operation to multiply x by (2m−1), then to perform an addition operation to add a constant for the purposes of rounding and then to perform a division operation to divide the result by (2n−1). These operations tend to give a reliable result for the value of y, but there may be a cost in terms of the silicon area and processing power, as well as the time taken to compute y by implementing these operations. Optimized implementations for performing the division operation are available.